<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">	
	<link rel="stylesheet" href="../../../NCProjectWeb/css/bootstrap.css">
	<link rel="stylesheet" href="../../../NCProjectWeb/css/bodystyle.css">
	<base href = "${pageContext.request.contextPath}"> 
	<title>All cities</title>
</head>
<body>
	<%@ page import="entities.City"%>
	<%@ page import="java.util.ArrayList" %>

	<div align="center">
		<h3>Все города</h3>	
	</div>
	
	<%
		ArrayList<City> list = (ArrayList<City>) request.getAttribute("cityList");
	%>

	<table class="table table-striped">
		<tr class="warning">
			<td align="center"><b>Город</b></td>
			<td align="center"><b>Код города</b></td>
			<td align="center"><b>Страна</b></td>
			<td align="center"><b>Edit</b></td>		
		</tr>
		 <% for (int i = 0; i < list.size(); i++) { %> 
	 		<tr>
	 			<td align="center"><%= list.get(i).getCityName() %></td>
	 			<td align="center"><%= list.get(i).getCityCode() %></td>
	 			<td align="center"><%= list.get(i).getCityLocation().getCountryName()%></td>
	 			<td align="center">
	 			<a href="<c:url value="../../NCProjectWeb/getParamsToEditCity" ><c:param name="id" value="<%=list.get(i).getCityCode()%>" /></c:url>" title="Редактировать"><span class="glyphicon glyphicon-pencil"></span></a>
	 			<a onClick = "drop(<%='\'' + list.get(i).getCityCode() + '\''%>)" title="Удалить"><span class="glyphicon glyphicon-trash"></span></a>
		 		</td>
	 		</tr>
		 <%	} %>
</table>
<div align="center">
	<a class="btn btn-default" href="<c:url value="/admin/index.jsp"/>" role="button">Home</a>
</div>
		
	<script>
        function drop(citycode) {
       	  if (confirm('Вы действительно хотите удалить город ' + citycode + '?')) {
			window.location = "../../NCProjectWeb/deleteCity?citycode=" + citycode;
          }
        };
    </script>
	
</body>
</html>
